package com.hibernate.home.oneTOone.model.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.jboss.logging.annotations.Transform;

@Entity
@Table(name="EmployeeDetails")
public class EmployeeDetail implements Serializable{

	private static final long serialVersionUID = 1L;
	

	private Integer id;
	private String email;
	private Date logintime;
	private String deparment;
	private Employee employee;
	
	
	@OneToOne(targetEntity=Employee.class, cascade=CascadeType.ALL)
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	@Id
	@SequenceGenerator(name="em_d_seq",sequenceName="em_d_seq",initialValue=0,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="em_d_seq")
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	public Date getLogintime() {
		return logintime;
	}
	public void setLogintime(Date logintime) {
		this.logintime = logintime;
	}
	public String getDeparment() {
		return deparment;
	}
	public void setDeparment(String deparment) {
		this.deparment = deparment;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EmployeeDetail other = (EmployeeDetail) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "EmployeeDetail [id=" + id + ", email=" + email + ", logintime="
				+ logintime + ", deparment=" + deparment + "]";
	}
	  
	
}
